package com.it.taoyidian.entity;

import lombok.Data;

@Data
public class ResponseResult<T>{
    private int code;
    private String message;
    private T data;

    public ResponseResult(T data) {
        this.code =ResultEnum.SUCCESS.getCode();
        this.message=ResultEnum.SUCCESS.getMessage();
        this.data=data;
    }
    public ResponseResult(int code, String message) {
        this.code = code;
        this.message = message;
    }
    public static <T> ResponseResult<T> success(T data) {
        return new ResponseResult<>(data);
    }
    public static <T> ResponseResult<T> success() {
        return new ResponseResult<>(null);
    }
    public static <T> ResponseResult<T> fail(ResultEnum resultEnum) {
        return new ResponseResult<>(resultEnum.getCode(),resultEnum.getMessage());
    }
}
